﻿using System;

namespace DACS.Web.Modules.MenuCategory
{
    public partial class MenuCategory : VIT.Web.UI.VITModule
    {
        MenuCat _menuCat = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            rpt.ItemDataBound += new System.Web.UI.WebControls.RepeaterItemEventHandler(rpt_ItemDataBound);
            rpt.ItemCreated += new System.Web.UI.WebControls.RepeaterItemEventHandler(rpt_ItemCreated);
            if (!IsPostBack)
            {
                CategoryProvider fnp = new CategoryProvider();
                fnp.LanguageId = Session["language"].ToString();
                _menuCat = fnp.GetMenuCategory(Params);

                rpt.DataSource = _menuCat.Data;
                rpt.DataBind();
            }
        }

        void rpt_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
            var rpt1 = e.Item.FindControl("rpt1") as System.Web.UI.WebControls.Repeater;
            if (rpt1 != null)
            {
                var dt = _menuCat.Children[e.Item.ItemIndex];
                rpt1.DataSource = dt.Data;
                rpt1.DataBind();
            }
        }

        void rpt_ItemCreated(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
        }
    }
}